package com.moorror.codegenvel.common.tree;

import com.intellij.openapi.project.Project;
import com.moorror.codegenvel.tab.TabJsonWrap;
import com.moorror.codegenvel.utils.JacksonUtils;
import lombok.Getter;

/**
 * @Author jiyanghuang
 * @Date 2022/8/7 12:32
 */
public class TreeRightPanelJson extends MRTreeRightPanel {

    @Getter
    private TabJsonWrap tabJsonWrap;

    public TreeRightPanelJson(Project project, Object data) {
        super(project);
        tabJsonWrap = new TabJsonWrap(project, 0, "JsonView", tabbedPane, JacksonUtils.toFormatJSONString(data), false);
    }

    public TreeRightPanelJson(Project project, Object data, String titleName) {
        super(project);
        tabJsonWrap = new TabJsonWrap(project, 0, titleName, tabbedPane, JacksonUtils.toFormatJSONString(data), false);
    }

    public String jsonValue() {
        return tabJsonWrap.text();
    }

    public void updateJsonValue(String jsonValue){
        tabJsonWrap.fillSource(jsonValue);
    }
}
